package utils

import (
    "reflect"
    // log "github.com/sirupsen/logrus"
    "strconv"
    "math/big"
)

func IsEmpty(a interface{}) bool {
    v := reflect.ValueOf(a)
    if v.Kind() == reflect.Ptr {
        v=v.Elem()
    }
    return v.Interface() == reflect.Zero(v.Type()).Interface()
}

func ArrStr2Int(params []string) []int{
    var paramSlice []int = make([]int, len(params))
    for key, param := range params {
        tmp, _ := strconv.Atoi(param)
        paramSlice[key] = tmp
    }
    return paramSlice
}

func PowBigInt(x *big.Int, n *big.Int) *big.Int {
	if n.Cmp(big.NewInt(0)) == 0 {
        return big.NewInt(1)
    } else {
		r := big.NewInt(1)
		for n.Cmp(big.NewInt(0)) > 0 {
			r.Mul(r, x)
			n.Sub(n, big.NewInt(1))
		}
        return r
	}
}